#include <iostream>
#include <iomanip>
#include <limits>
#include <cassert>

using namespace std;

bool print(int i, int base = 10)
{
    switch(base){
    case 10:
        cout << i << endl;
        break;
    case 16:
        cout << hex << i << endl;
        break;
    case 8:
        cout << oct << i << endl;
        break;
    default:
        cout << "unsupported base" << endl;
    }
        
}
void print2(int input , int base = 10)
{
    const char DIGITS[]="0123456789ABCDEF";
    const int MAX = 12;
    assert(MAX <= numeric_limits<int>::digits);
    char ret[MAX+2];
    for(int i = 0; i < MAX + 2; i++)
        ret[i] = ' ';
    
    ret[MAX+1] = '\0';
    
    if( input < 0){
        input = -input;
        ret[0] = '-';
    }
    else{
        ret[0] = '+';
    }
    char* p = &ret[MAX];
    for(; input != 0; input /= base){
        *p-- = DIGITS[input%base];
    }

    cout << ret << endl;
    
}

int main()
{
    print(11);
    print(1111111,16);
    print(1111111,8);
    
    print2(1111111);
    print2(1111111,16);
    print2(1111111,8);
}
